﻿using System;
using System.Collections.Generic;
using System.Text;

namespace HZY.EFCore.Interface
{
    using System.Linq;
    using System.Linq.Expressions;
    using System.Threading.Tasks;

    public interface IRepository<T>
    where T : class, new()
    {
        IQueryable<T> Query();

        IQueryable<T> Query(Expression<Func<T, bool>> Where);

        #region 异步方法

        Task<T> InsertAsync(T model);

        Task<int> UpdateAsync(T model);

        Task<int> UpdateByIdAsync(T model);

        Task<int> UpdateAsync(Expression<Func<T, T>> model, Expression<Func<T, bool>> expWhere);

        Task<int> DeleteAsync(T model);

        Task<int> DeleteRangeAsync(IEnumerable<T> models);

        Task<T> FindByIdAsync(object Key);

        Task<T> FindAsync(Expression<Func<T, bool>> Where);

        Task<List<T>> FindListAsync(Expression<Func<T, bool>> Where);

        Task<List<T>> FindAllAsync();

        Task<int> CountAsync();

        #endregion

        #region 同步方法

        T Insert(T model);

        int Update(T model);

        int UpdateById(T model);

        int Update(Expression<Func<T, T>> model, Expression<Func<T, bool>> expWhere);

        int Delete(T model);

        int DeleteRange(IEnumerable<T> models);

        T FindById(object Key);

        T Find(Expression<Func<T, bool>> Where);

        List<T> FindList(Expression<Func<T, bool>> Where);

        List<T> FindAll();

        int Count();

        #endregion

    }
}
